home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // Yahoo!Cinema
-
- (***************************************************
- * Movie importation script for: *
- * Yahoo!Cinema (IT), http://it.movies.yahoo.com *
- * *
- * (c) 2003 Andrea Cristaudo achris@tiscalinet.it *
- * *
- * For use with Ant Movie Catalog 3.4.1 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
-
- program YahooCinema;
- var
- MovieName: string;
- TheMovieAddress: string;
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: integer;
- BeginPos: integer;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
- LineNr := FindLine('<font face=arial,helvetica size=+1><b>Risultati ricerca</b></font>', Page, 0);
- if LineNr = -1 then
- begin
- SetField(fieldURL, Address);
- AnalyzeMoviePage(Page);
- end
- else
- begin
- PickTreeClear;
- AddMoviesTitles(Page);
- if TheMovieAddress='' then
- begin
- if PickTreeExec(Address) then
- begin
- SetField(fieldURL, Address);
- Page.Text := GetPage(Address);
- AnalyzeMoviePage(Page);
- end;
- end
- else
- begin
- SetField(fieldURL, TheMovieAddress);
- Page.Text := GetPage(TheMovieAddress);
- AnalyzeMoviePage(Page);
- end;
- end;
- Page.Free;
- end;
-
- procedure AnalyzeMoviePage(Page: TStringList);
- var
- Fine: Integer;
- Line: string;
- LineNr: Integer;
- BeginPos, EndPos: Integer;
- Field: integer;
- begin
- Fine := 0;
- LineNr := FindLine('<td><font face=arial size=+1 color="#333366"><b>', Page, 0);
- if LineNr > -1 then
- begin
- //Translated Title
- Line := Page.GetString(LineNr);
- HTMLRemoveTags(Line);
-
- SetField(fieldTranslatedTitle, copy(Line, 1, pos(' (', Line)));
- Delete(Line, 1, pos(' (', Line) + 1);
- Delete(Line, pos(')', Line), pos(')', Line) + 1);
- SetField(fieldYear, Line);
-
- repeat
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
-
- if pos('<b>Genere: </b>', Line) = 1 then
- begin
- HTMLRemoveTags(Line);
- Delete(Line, 1, 8);
- SetField(fieldCategory, Line);
- end
- else if pos('<b>Durata: </b>', Line) = 1 then
- begin
- HTMLRemoveTags(Line);
- Delete(Line, 1, 8);
- BeginPos := pos(' - ', Line);
-
- SetField(fieldLength, copy(Line, 1, BeginPos - 1));
-
- Delete(Line, 1, BeginPos + 11);
- SetField(fieldCountry, Line);
-
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- HtmlRemoveTags(Line);
- SetField(fieldDescription, Line);
- end
- else if pos('<b>Titolo Originale: </b>', Line) = 1 then
- begin
- HTMLRemoveTags(Line);
- Delete(Line, 1, 18);
- SetField(fieldOriginalTitle, Line);
- end
- else if pos('<b>Regia:</b>', Line) <> 0 then
- begin
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- HtmlRemoveTags(Line);
- SetField(fieldDirector, Line);
- end
- else if pos('<b>Prodotto da:</b>', Line) <> 0 then
- begin
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- HtmlRemoveTags(Line);
- SetField(fieldProducer, Line);
- end
- else if pos('<b>Attori:</b>', Line) <> 0 then
- begin
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- HtmlRemoveTags(Line);
- SetField(fieldActors, Line);
- end
- else if pos('alt="Immagine"', Line) <> 0 then
- begin
- Delete(Line, 1, pos('<img ', Line) + 10);
- Delete(Line, pos('" width=', Line), pos('>', Line) + 1);
- GetPicture(Line, False);
- end
-
- else if Line = '</html>' then
- Fine := 1;
- until Fine = 1;
- end;
- DisplayResults;
- end;
-
- procedure AddMoviesTitles(Page: TStringList);
- var
- LineNr: Integer;
- NewLineNr: Integer;
- Line: string;
- MovieTitle, MovieAddress: string;
- BeginPos, EndPos: Integer;
- begin
- TheMovieAddress := '*';
- LineNr := 0;
- LineNr := FindLine('<font face=arial,helvetica><b>Risulati Film</b>',Page,LineNr);
- LineNr := LineNr + 3;
- while LineNr > 2 do
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('<li><b><a href="',Line)+16;
- EndPos := pos('">',Line);
- MovieAddress := copy(Line,BeginPos,EndPos-BeginPos);
- Delete(Line,1,EndPos + 1);
- BeginPos := 1;
- EndPos := -1;
- MovieTitle := Line;
- HTMLRemoveTags(MovieTitle);
- HTMLDecode(Movietitle);
- PickTreeAdd(MovieTitle, MovieAddress);
-
- NewLineNr := FindLine('<li><b><a href="',Page,LineNr+1);
- if NewLineNr <> (LineNr + 1) then
- LineNr := 2
- else
- LineNr := NewLineNr;
-
- if TheMovieAddress='*' then
- TheMovieAddress := MovieAddress
- else
- TheMovieAddress := '';
- end;
- if TheMovieAddress='*' then TheMovieAddress := '';
- end;
-
- begin
- if CheckVersion(3,4,1) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- if Input('Yahoo!Cinema Import', 'Enter the title of the movie:', MovieName) then
- begin
- AnalyzePage('http://it.search.movies.yahoo.com/search/movies_db_it?mt='+UrlEncode(MovieName));
- end;
- end else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.1)');
- end.
-